package com.zzyl.nursing.service.impl;

import java.util.List;

import com.zzyl.nursing.dto.NursingTaskCancelDto;
import com.zzyl.nursing.dto.NursingTaskDoDto;
import com.zzyl.nursing.dto.NursingTaskUpdateTimeDto;
import com.zzyl.nursing.vo.NursingTaskVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzyl.nursing.mapper.NursingTaskMapper;
import com.zzyl.nursing.domain.NursingTask;
import com.zzyl.nursing.service.INursingTaskService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 护理任务Service业务层处理
 *
 * @author alexis
 * @date 2024-11-17
 */
@Service
public class NursingTaskServiceImpl extends ServiceImpl<NursingTaskMapper, NursingTask> implements INursingTaskService {
    @Autowired
    private NursingTaskMapper nursingTaskMapper;

    /**
     * 查询护理任务列表
     *
     * @param nursingTask 护理任务
     * @return 护理任务
     */
    @Override
    public List<NursingTask> selectNursingTaskList(NursingTask nursingTask) {
        return nursingTaskMapper.selectNursingTaskList(nursingTask);
    }


    /**
     * 取消护理任务
     */
    @Override
    public int cancel(NursingTaskCancelDto nursingTaskCancelDto) {
        NursingTask nursingTask = new NursingTask();
        nursingTask.setId(nursingTaskCancelDto.getTaskId());
        nursingTask.setCancelReason(nursingTaskCancelDto.getReason());
        nursingTask.setStatus(3);
        return updateById(nursingTask) ? 1 : 0;

    }

    /**
     * 执行护理任务
     */
    @Override
    public int doTask(NursingTaskDoDto nursingTaskDoDto) {
        NursingTask nursingTask = new NursingTask();
        nursingTask.setId(nursingTaskDoDto.getTaskId());
        nursingTask.setRealServerTime(nursingTaskDoDto.getEstimatedServerTime());
        nursingTask.setMark(nursingTaskDoDto.getMark());
        nursingTask.setTaskImage(nursingTaskDoDto.getTaskImage());
        nursingTask.setStatus(2);
        return updateById(nursingTask) ? 1 : 0;
    }

    /**
     * 任务改期
     */
    @Override
    public int updateTime(NursingTaskUpdateTimeDto nursingTaskUpdateTimeDto) {
        NursingTask nursingTask = new NursingTask();
        nursingTask.setId(nursingTaskUpdateTimeDto.getTaskId());
        nursingTask.setEstimatedServerTime(nursingTaskUpdateTimeDto.getEstimatedServerTime());
        return updateById(nursingTask) ? 1 : 0;
    }

    /**
     * 根据id查询护理任务
     */
    @Override
    public NursingTaskVo selectNursingTaskById(Long id) {
        return nursingTaskMapper.selectNursingTaskById(id);
    }

}
